package com.example.a2032.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.a2032.db.DataDbHelper;
import com.example.a2032.db.dao.TempDataDao;
import com.example.a2032.livedatas.SingleSourceLiveData;
import com.example.a2032.entity.TempData;

import java.util.List;

public class TempDataViewModel extends AndroidViewModel {

    private final SingleSourceLiveData<List<TempData>> realTimeStepObservable;
    TempDataDao tempDataDao;

    public TempDataViewModel(@NonNull Application application) {
        super(application);
        tempDataDao = DataDbHelper.getInstance(application).getTempDataDao();
        realTimeStepObservable = new SingleSourceLiveData<>();
    }

    public LiveData<List<TempData>> getSleepData(String startDate,String endDate){
        realTimeStepObservable.setSource(tempDataDao.loadTempData(startDate,endDate));
        return  realTimeStepObservable;
    }
}
